import { mock } from 'mockjs';
import type { MockMethod } from 'vite-plugin-mock';

const apis: MockMethod[] = [
  {
    url: '/mock/getArticleList',
    method: 'post',
    response: (): Service.MockServiceResult<ApiArticle.Article[]> => {
      const data = mock({
        'list|10': [
          {
            id: '@id',
            title: '@title',
            pub_date: '@pub_date',
            state: '@state',
            cate_name: '@cate_name'
          }
        ]
      });

      return {
        code: 200,
        message: 'ok',
        data: data.list
      };
    }
  },
  {
    url: '/mock/getChannelList',
    method: 'post',
    response: (): Service.MockServiceResult<ApiArticle.Channel[]> => {
      const data = mock({
        'list|2': [
          {
            cate_id: '@cate_id',
            cate_name: '@title',
            cate_alias: '@cate_alias'
          }
        ]
      });

      return {
        code: 200,
        message: 'ok',
        data: data.list
      };
    }
  }
];
export default apis;
